{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# sklearn中的多项式回归和Pipeline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "x = np.random.uniform(-3, 3, size=100)\n",
    "X = x.reshape(-1, 1)\n",
    "y = 0.5 * x**2 + x + 2 + np.random.normal(0, 1, size=100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.preprocessing import PolynomialFeatures"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "poly  = PolynomialFeatures(degree=2) # degree表示最多添加几次幂"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "PolynomialFeatures(degree=2, include_bias=True, interaction_only=False)"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "poly.fit(X)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "X2 = poly.transform(X)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 1.        , -0.14086366,  0.01984257],\n",
       "       [ 1.        ,  1.05124882,  1.10512408],\n",
       "       [ 1.        ,  1.33415974,  1.77998222],\n",
       "       [ 1.        , -0.1531774 ,  0.02346332],\n",
       "       [ 1.        ,  1.77559373,  3.15273308]])"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X2[:5, :]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.linear_model import LinearRegression\n",
    "lin_reg2 = LinearRegression()\n",
    "lin_reg2.fit(X2, y)\n",
    "y_predict2 = lin_reg2.predict(X2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD8CAYAAABn919SAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAIABJREFUeJzt3Xt4VOW1x/HvIgYIKKISFQKKWIuiVKnUC1QF8QiKAnLxiFpvVFp7tGIVxaMVr0DFU/VUbbWo1eIV0RwvCIqAVFQ0CF4QQVQEggpYuSgIIbznj51ALjOZycye2XtPfp/nyQOZTGa/k2TWfme9a6/XnHOIiEj0NQp6ACIi4g8FdBGRHKGALiKSIxTQRURyhAK6iEiOUEAXEckRCugiIjlCAV1EJEcooIuI5IhdsnmwVq1aufbt22fzkCIikTdv3ry1zrnCRPfLakBv3749JSUl2TykiEjkmdmXydxPKRcRkRyhgC4ikiMU0EVEcoQCuohIjlBAFxHJEVmtchERaSiK55cyftpiVq3bTJuWBYzs3ZEBXYoyekwFdBERnxXPL+XaZz9kc1k5AKXrNnPtsx8CZDSoK+UiIuKz8dMW7wjmlTaXlTN+2uKMHlcBXUTEZ6vWba7X7X5RQBcR8VmblgX1ut0vCQO6mT1kZqvN7KMqt+1pZq+a2acV/+6R0VGKiETIyN4dKcjPq3ZbQX4eI3t3zOhxk5mh/wPoU+O2UcBrzrmDgNcqPhcREbyFz7EDO1PUsgADiloWMHZg5+CrXJxzs82sfY2b+wM9Kv7/CDALuMbHcYmIRNqALkUZD+A1pZpD38c59xVAxb97x7ujmQ03sxIzK1mzZk2KhxMRkUQyvijqnHvAOdfVOde1sDBhO18REUlRqgH9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Y0Ul5WJmLZxzGyr+/3ugk3PutwEPKyVmdjIwwzm3zcz+BOCcuybgYaXEzA4BtgP3A1c550oCHlLSzCwPWAL8B7ASeBcY6pz7ONCBpcjMjge+Bx51zh0W9HjSYWatgdbOuffMbDdgHjAgir8bMzOguXPuezPLB94ALnfOve33sSIzQ68M5hWaA9E4E8XgnHvFObet4tO3gbZBjicdzrlFzrmobm56FLDUOfe5c24r8CTQP+Axpcw5Nxv4d9Dj8INz7ivn3HsV/98ILAIi2T/aeb6v+DS/4iMj8SsyAR3AzG4zsxXAOcANQY/HJxcBLwc9iAaqCFhR5fOVRDRo5DIzaw90AeYGO5LUmVmemS0AVgOvOucy8lxCFdDNbLqZfRTjoz+Ac+4651w74DHg0mBHW7dEz6XiPtcB2/CeT2gl81wiymLcFtl3frnIzHYFJgMjarxLjxTnXLlz7gi8d+NHmVlGUmKh2rHIOXdSknd9HHgJGJ3B4aQl0XMxs/OB04BeLuQLGfX4vUTNSqBdlc/bAqsCGovUUJFvngw85px7Nujx+ME5t87MZgF9AN8Xr0M1Q6+LmR1U5dN+wCdBjSVdZtYHuAbo55zbFPR4GrB3gYPM7AAzawycBTwf8JiEHQuJDwKLnHN/Dno86TCzwspKNjMrAE4iQ/ErSlUuk4GOeBUVXwK/dc6VBjuq1JjZUqAJ8G3FTW9HuGLnDOAvQCGwDljgnOsd7KiSZ2anAncBecBDzrnbAh5SyszsCaAHXle/b4DRzrkHAx1Uiszsl8C/gA/xXvMA/+2cmxLcqFJjZj8DHsH7G2sEPO2cuzkjx4pKQBcRkbpFJuUiIiJ1U0AXEckRCugiIjlCAV1EJEcooIuI5AgFdBGRHKGALiKSIxTQRURyxP8D5X2bz4gO/WIAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(x, y)\n",
    "plt.plot(np.sort(x), y_predict2[np.argsort(x)], color='r')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 0.        ,  0.85467025,  0.4819649 ])"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "lin_reg2.coef_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2.1066531733841476"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "lin_reg2.intercept_"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "> PolynomialFeatures当幂数上升的时候回导致X的列数快速上升"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 使用sklearn中的Pipeline来完成多项式回归"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "'''重要'''\n",
    "x = np.random.uniform(-3, 3, size=100)\n",
    "X = x.reshape(-1, 1)\n",
    "y = 0.5 * x**2 + x + 2 + np.random.normal(0, 1, 100)\n",
    "\n",
    "from sklearn.pipeline import Pipeline\n",
    "from sklearn.preprocessing import StandardScaler\n",
    "\n",
    "poly_reg = Pipeline([\n",
    "    (\"poly\", PolynomialFeatures(degree=2)),\n",
    "    (\"std_scaler\", StandardScaler()),\n",
    "    (\"lin_reg\", LinearRegression())\n",
    "])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "poly_reg.fit(X, y)\n",
    "y_predict = poly_reg.predict(X)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAW4AAAD8CAYAAABXe05zAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdh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ch5AFrq32+jgAHhXRnjGkJtAfmeDuS+BhjsowxC4EfgJnW2oS9npQEbmPMO8aYL0J8dAew1t5trT0MGAfckooxxaO211P5mLuBXTivydfcvJ6AMyG+Fug7u3RljNkPmAD0qXE3HjjW2nJrbTucu+7jjTEJS2ml5AQca+1pLh/6H2AqMDCJw4lbba/HGHM10A3obL1eRHAhir+foFoHHFbt80OBbz0ai4RRmQueAIyz1k70ejyJYq0tMca8D5wJJGQx2fNUiTHmqGqfngss82osiWCMORO4EzjXWrvN6/EI4CxGHmWMOcIYUw+4BJjs8ZikmsrFvNHAUmvtY16PJ17GmGZVFWXGmBzgNBIY2/xQVTIBaINTubAauNFaW+zpoOJgjFkB1Ac2Vn7pk4BXyZwHPAk0A0qAhdbaLt6OKnrGmLOBx4Es4Dlr7YMeDykuxpiXgT/hdJ77HhhorR3t6aDiYIz5A/AB8DlOLADob62d5t2oYmeMORZ4Eef9VgcYb629P2HX9zpwi4hIdDxPlYiISHQUuEVEAkaBW0QkYBS4RUQCRoFbRCRgFLhFRAJGgVtEJGAUuEVEAub/AW6DOmBIwRdNAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(x, y)\n",
    "plt.plot(np.sort(x), y_predict[np.argsort(x)], color='r')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
